//
//  HYCollectionViewCellForT20.m
//  TTLestening
//
//  Created by dllo on 16/3/29.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "HYCollectionViewCellForT20.h"
#import "HYModelForRecommend.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface HYCollectionViewCellForT20 ()

@property (nonatomic, strong) UILabel *labelForReason;
@property (nonatomic, strong) UILabel *labelForName;
@property (nonatomic, strong) UIImageView *imageView;

@end
@implementation HYCollectionViewCellForT20

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubViews];
    }
    
    return self;
}

#pragma mark - createSubViews
- (void)createSubViews {
    
    self.labelForReason = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForReason];
    self.labelForReason.textColor = [UIColor grayColor];
    self.labelForReason.textAlignment = 1;
    self.labelForReason.font = [UIFont systemFontOfSize:14];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    self.labelForName.textAlignment = 1;
    self.labelForName.font = [UIFont boldSystemFontOfSize:16];
    
    self.imageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageView];
    self.imageView.layer.cornerRadius = 60;
    self.imageView.layer.masksToBounds = YES;
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.labelForReason.frame = CGRectMake(0, self.contentView.frame.size.height / 5, self.contentView.frame.size.width, 30);
    self.imageView.frame = CGRectMake(self.frame.size.width / 2.5, self.frame.size.height / 2.5, self.frame.size.width / 2, self.frame.size.height / 2);
    self.labelForName.frame = CGRectMake(0, 300, self.contentView.frame.size.width, 40);
    
}

- (void)passMoldel:(HYModelForRecommend *)model {
    
    self.labelForReason.text = model.reason;
    self.labelForName.text = model.name;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.picUrl] placeholderImage:[UIImage imageNamed:@"iconfont-jiazai"]];
}


@end
